<?php
include "./lib/dll.class.php";
$c = new windll('msvcrt.dll',__CDECL);

/*
$fp = $c->fopen("io.txt\0","wb+\0");
$string = 'hello world';
$c->fwrite($string,strlen($string),1,$fp);
$c->fclose($fp);
*/

$fp = $c->fopen("\\\\.\\PHYSICALDRIVE0\0","rb\0");
if($fp != 0)
{
	$buffer = str_repeat("\0",512);
	$c->fread(array(&$buffer,512,1,$fp));
	$c->fclose($fp);
	
	echo "    00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\r\n";
	echo "---------------------------------------------------\r\n";
	for($i=0;$i<32;$i++)
	{
		echo sprintf('%03d ',$i);
		for($j=0;$j<16;$j++)
		{
			echo sprintf("%02X ",ord($buffer{$i*16+$j}));
		}
		for($j=0;$j<16;$j++)
		{
			$ch = $buffer{$i*16+$j};
			if($c->isprint(ord($ch))) echo $ch;
			else echo '.';
		}
		echo "\r\n";
	}
}

if(php_sapi_name()=='cli')system("pause");